﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yto.EF.UW;
using Yto.Unitwork;

namespace Yto.EF.DbCtx
{
    public class DbProvider<T> : IDbProvider<T> where T : DbContext
    {
        private ICurrentUnit _currentUnit;

        public DbProvider(ICurrentUnit currentUnit)
        {
            _currentUnit = currentUnit;
        }

        public T GetDbContext()
        {
            return (_currentUnit.Current as EFUnitwork).GetDbContext<T>(); ;
        }
    }
}
